package com.cqgc.service.impl;

import com.cqgc.dao.BookDao;
import com.cqgc.domain.Book;
import com.cqgc.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author fengzongfu
 */
@Service
@Transactional
public class BookServiceImpl implements BookService {

    //注入BookDao对象
    @Autowired
    private BookDao bookDao;

    @Override
    public void save(Book book) {
        bookDao.save(book);
    }

    @Override
    public void delete(Integer id) {
        bookDao.delete(id);
//        int a = 1/0;
    }

    @Override
    public void update(Book book) {
        bookDao.update(book);
    }

    @Override
    public List<Book> getAll() {
        return bookDao.getAll();
    }

    @Override
    public Book getById(Integer id) {
        return bookDao.getById(id);
    }
}
